package com.example.supplychainbackend.controller.dto;

import lombok.Data;

@Data
public class DataResponse<T> {
    private int code;
    private String message;
    private T data;

    public DataResponse(int code, String message, T data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> DataResponse<T> success(T data) {
        return new DataResponse<>(200, "success", data);
    }

    public static <T> DataResponse<T> error(int code, Exception e) {
        e.printStackTrace();
        return new DataResponse<>(code, e.getMessage(), null);
    }
}